home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / blitzbasic / blitz-list200994.lha / blitz-list / 000222_blitz-list-request_Thu Aug 18 01:32:27 1994.msg < prev    next >
Internet Message Format  |  1994-09-20  |  7KB

  1. Received: from zeus (zeus.usq.edu.au [139.86.128.2]) by kantti.helsinki.fi (8.6.9/8.6.5) with SMTP id BAA12493 for <blitz-list@helsinki.fi>; Thu, 18 Aug 1994 01:31:11 +0300
  2. Received: from helios.usq.edu.au (helios) by zeus with SMTP id AA12663
  3.   (5.65c/IDA-1.4.4 for <blitz-list@helsinki.fi>); Thu, 18 Aug 1994 08:22:57 -1000
  4. Message-Id: <199408181822.AA12663@zeus>
  5. Received: by helios.usq.edu.au
  6. From: "neil o'rourke" <orourke@zeus.usq.edu.au>
  7. Subject: Moving Bitplanes
  8. To: blitz-list@helsinki.fi
  9. Date: Thu, 18 Aug 1994 08:16:42 +1000 (EST)
  10. MIME-Version: 1.0
  11. Content-Type: text/plain; charset="us-ascii"
  12. Content-Transfer-Encoding: 7bit
  13. X-Status: 
  14. Status: O
  15.  
  16.  > > > 
  17.  > > >   How can I move an individual bitplane in a bitmap??
  18.  > > > 
  19.  > 
  20.  > > What do you mean exactly, "move an individual bitplane in a bit map"?
  21.  > 
  22.  > > You can simulate this effect by having a large off-screen bitmap, and
  23.  > > copy over (or blit over) the section needed into the specified bitmap.
  24.  > 
  25.  > > If this is what you want, I've written some code to allow you use the
  26.  > > blitter for this purpose.
  27.  > 
  28.  > What I would like, is to be able to draw into a specific bitplane
  29.  > (using BitPlanesBitMap), and then scrolling this individual
  30.  > bitplane around on top of the existing bitmap.
  31.  > 
  32.  > I would greatly appreciate looking at your code, to see if that
  33.  > does the trick!  Thanks.
  34.  
  35.  I don't know if this is really what you want, but it might give you
  36.  ideas.  This code uses the blitter directly to move data around a
  37.  bitplane, and could simulate the effect you are after.
  38.  
  39.  This code runs under Intuition, but I didn't bother protecting myself
  40.  with a call to OwnBlitter() and DisownBlitter().  The routines adapt
  41.  themselves to whatever strange bitmaps you care to toss at it, and even
  42.  works on my 4000/040 here at work.
  43.  
  44.  Regards,
  45.  
  46.  Neil
  47.  
  48.  -------------------------------------------------------------------------
  49. NEWTYPE.CBMParams
  50. ;This newtype is the sole parameter to the CopyBM2 statement
  51.   SBM.w     ;Source BitMap number
  52.   DBM.w     ;Destination BitMap number (can be the same as Source)
  53.  
  54.   X1.w      ;\
  55.   Y1.w      ; | Rectangle to cut
  56.   W.w       ; | from source
  57.   H.w       ;/
  58.  
  59.   X2.w      ;\ Destination for
  60.   Y2.w      ;/ the Blit
  61.  
  62.   SrcBP.w   ;What bitplane to get image from.
  63.   DestBP.w  ;This parameter tell the routine what bitplane to sent
  64.             ;the src image to.  Ignored if -1.
  65.  
  66. End NEWTYPE
  67.  
  68. NEWTYPE.bitmap
  69.   _ebwidth.w  ;even byte width of a bitmap
  70.   _height.w   ;pixel height of bitmap
  71.   _depth.w    ;depth, in bitplanes, of bitmap
  72.   _pad.b[2]
  73.   _data.l[8]  ;Max of 8 pointers to bitplanes
  74.   _pad2.b[22]
  75.   _isreal.w   ;=0: no bitmap present
  76.               ;<0: bitmap present
  77.               ;>0: bitmap present, but not ours
  78. End NEWTYPE
  79.  
  80. #custom=$dff000       ;address of chip registers ("the metal")
  81.  
  82. #BLTCON0=#custom+$40  ;Blitter control register 0
  83. #BLTCON1=#custom+$42  ;   "       "       "     1
  84. #BLTAFWM=#custom+$44  ;Blitter first word mask for source A
  85. #BLTALWM=#custom+$46  ;   "    last   "    "    "    "    "
  86. #BLTCPTH=#custom+$48  ;Blitter pointer to source C (high 3 bits)
  87. #BLTCPTL=#custom+$4a  ;   "       "    "    "    " (low 15 bits)
  88. #BLTBPTH=#custom+$4c  ;Blitter pointer to source B (high 3 bits)
  89. #BLTBPTL=#custom+$4e  ;   "       "    "    "    " (low 15 bits)
  90. #BLTAPTH=#custom+$50  ;Blitter pointer to source A (high 3 bits)
  91. #BLTAPTL=#custom+$52  ;   "       "    "    "    " (low 15 bits)
  92. #BLTDPTH=#custom+$54  ;Blitter pointer to destination D (high 3 bits)
  93. #BLTDPTL=#custom+$56  ;   "       "    "       "      " (low 15 bits)
  94. #BLTSIZE=#custom+$58  ;Blitter start and size (window width,height)
  95. #BLTCON0L=#custom+$5a ;Blitter control 0, lower 8 bits (minterms)
  96. #BLTSIZV=#custom+$5c  ;Bliter V size (for 15 bit vertical size)
  97. #BLTSIZH=#custom+$5e  ;Blitter H size and start (for 11 bit H size)
  98. #BLTCMOD=#custom+$60  ;Blitter modulo for source C
  99. #BLTBMOD=#custom+$62  ;Blitter modulo for source B
  100. #BLTAMOD=#custom+$64  ;Blitter modulo for source A
  101. #BLTDMOD=#custom+$66  ;Blitter modulo for destination D
  102. #BLTCDAT=#custom+$70  ;Blitter source C data register
  103. #BLTBDAT=#custom+$72  ;Blitter source B data register
  104. #BLTADAT=#custom+$74  ;Blitter source A data register
  105.  
  106. #DMACONR=#custom+$02  ;DMA control register (read only)
  107.  
  108. #DMAB_BLTDONE=14
  109.  
  110. Macro WaitBlit
  111. ;This little macro busy-waits until the blitter is free
  112. BTST.b #DMAB_BLTDONE-8,DMACONR
  113. waitblit2: BTST.b #DMAB_BLTDONE-8,DMACONR:BNE waitblit2
  114. End Macro
  115.  
  116. Statement CopyBM2{*BMP.CBMParams}
  117. ;This statement copys a rectangular section from SBM to DBM using
  118. ;the Blitter.
  119.  
  120.   DEFTYPE.bitmap *src,*dest
  121.  
  122. ;get pointers to the bitmaps
  123.   *src=Addr BitMap(*BMP\SBM)
  124.   *dest=Addr BitMap(*BMP\DBM)
  125.  
  126. ;Extract the data that we want
  127.   SrcX.w=*BMP\X1/8      ;Result in bytes
  128.   SrcY.w=*BMP\Y1        ;Result in scanlines
  129.   SizeX.w=*BMP\W/8      ;Result in bytes
  130.   SizeY.w=*BMP\H        ;Result in scanlines
  131.   DestX.w=*BMP\X2/8     ;Result in bytes
  132.   DestY.w=*BMP\Y2       ;Result in scanlines
  133.   DDpth.w=*src\_depth   ;could use Depth(*BMP\SBM)
  134.  
  135.   ImageSPointer.w=(*src\_ebwidth*SrcY)+SrcX     ;This becomes our BLTAPTH
  136.   ImageSModulo.w =*src\_ebwidth-SizeX           ;This becomes our BLTAMOD
  137.  
  138.   ImageDPointer.w=(*dest\_ebwidth*DestY)+DestX  ;This becomes our BLTDPTH
  139.   ImageDModulo.w =*dest\_ebwidth-SizeX          ;This becomes our BLTDMOD
  140.  
  141.   BlitSize.w=(SizeY*64)+(SizeX/2)               ;This is the size of the blit
  142.  
  143.   If *BMP\DestBP=-1
  144.     For PlaneCount.w=0 To DDpth-1
  145.       !WaitBlit    ;Make sure the blitter isn't busy
  146.       Poke.w #BLTCON0,%0000100111110000 ;Enable A and D channels, MinTerm =$f0
  147.       Poke.w #BLTCON1,%0000000000000000
  148.       Poke.w #BLTAMOD,ImageSModulo
  149.       Poke.w #BLTDMOD,ImageDModulo
  150.       Poke.w #BLTAFWM,$ffff
  151.       Poke.w #BLTALWM,$ffff
  152.       Poke.l #BLTAPTH,*src\_data[PlaneCount]+ImageSPointer
  153.       Poke.l #BLTDPTH,*dest\_data[PlaneCount-1]+ImageDPointer
  154.       Poke.w #BLTSIZE,BlitSize  ;This starts the blit
  155.     Next PlaneCount
  156.   Else
  157.     Poke.w #BLTCON0,%0000100111110000 ;Enable A and D channels, MinTerm =$f0
  158.     Poke.w #BLTCON1,%0000000000000000
  159.     Poke.w #BLTAMOD,ImageSModulo
  160.     Poke.w #BLTDMOD,ImageDModulo
  161.     Poke.w #BLTAFWM,$ffff
  162.     Poke.w #BLTALWM,$ffff
  163.     Poke.l #BLTAPTH,*src\_data[*BMP\SrcBP]+ImageSPointer
  164.     Poke.l #BLTDPTH,*dest\_data[*BMP\DestBP]+ImageDPointer
  165.     Poke.w #BLTSIZE,BlitSize  ;This starts the blit
  166.   End If
  167. End Statement
  168.  
  169. ;Now test the routine to demonstrate.
  170.  
  171. Screen 0,0,0,320,256,6,$80,"",2,1
  172. ScreensBitMap 0,0
  173. BitMapOutput 0
  174. For x.w=0 To 31
  175.   Boxf x*5,x*4,320-(x*5),256-(x*4),x
  176. Next
  177.  
  178. DEFTYPE.CBMParams Txt,Erase
  179.  
  180. BitMap 1,320,256,1
  181. BitMapOutput 1:Locate 0,0:Print "HALF-BRIGHT TEXT"
  182. Txt\SBM=1
  183. Txt\DBM=0
  184. Txt\X1=0,0
  185. Txt\W=16*8,8
  186. Txt\X2=16,16
  187. Txt\SrcBP=0
  188. Txt\DestBP=5
  189. Erase\SBM=1
  190. Erase\DBM=0
  191. Erase\X1=0,9
  192. Erase\W=16*8,8
  193. Erase\X2=16,16
  194. Erase\SrcBP=0
  195. Erase\DestBP=5
  196.  
  197. OldX.w=0:OldY.w=0
  198.  
  199. For x.w=0 To (320-(16*8)) Step 8
  200.   For y.w=0 To 248
  201.     If (x MOD 16)=0 Then cy=y Else cy=248-y
  202.     Txt\X2=x,cy
  203.     Erase\X2=OldX,OldY
  204.     OldX=x:OldY=cy
  205.     VWait:CopyBM2{&Erase}:CopyBM2{&Txt}:VWait
  206.   Next y
  207. Next x
  208. End
  209.  
  210. ------------------------------------------------------------------------
  211.  
  212. orourke@helios.usq.edu.au
  213.  
  214.  
  215.  
  216.